package com.lizba.redis.limit.funnel;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 *
 * </p>
 *
 * @Author: Liziba
 * @Date: 2021/9/7 21:18
 */
public class TestFunnelRateLimit {

    public static void main(String[] args) throws InterruptedException {

        FunnelRateLimiter limiter = new FunnelRateLimiter();
        for (int i = 1; i <= 20; i++) {
            if (i == 15) {
                TimeUnit.SECONDS.sleep(2);
            }
            boolean success = limiter.isActionAllowed("Liziba", "commit", 10, 0.002f, 1);
            System.out.println("第" + i + "请求" + (success ? "成功" : "失败"));
        }

    }

}
